package com.spingbootes.kizuki.es;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

@Component
public class ExecuteUtil<T>{

    @Async
    public Future asyncExecute(Caller c) {
        return new AsyncResult(c.call());
    }

    public T execute(Caller c){
        return (T) c.call();
    }

    public interface Caller<T>{
        public T call();
    }

}
